<template>
    <div class="content">
        <el-table :data="EStableData" border style="width:100%" :header-cell-style="{ padding: '8px !important' }">
            <el-table-column fixed prop="id" label="ID">
            </el-table-column>
            <el-table-column prop="name" label="学科">
            </el-table-column>
            <el-table-column prop="levelName" label="年级">
            </el-table-column>
            <el-table-column fixed="right" label="操作">
                <template slot-scope="scope">
                    <el-button @click="redact(scope.row)">编辑</el-button>
                    <el-button @click="handleClick(scope.row)" type="danger">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import { mapMutations, mapState } from 'vuex'
export default {
    methods: {
        ...mapMutations(['EShttp']),
        // 删除
        handleClick(row) {
            this.axios.post(`/api/admin/education/subject/delete/${row.id}`).then(res => {
                console.log(res);
            })
            this.EShttp()
        },
        // 编辑
        redact(row) {
            window.sessionStorage.setItem('row', JSON.stringify(row))
            this.$router.push("/education/redact")
        },

    },
    mounted() {
        this.EShttp()
    },
    computed:{
        ...mapState(['EStableData']),
    }
}
</script>

<style lang="scss" scoped>
::v-deep .el-table .el-table__cell {
    padding: 2px !important;
}
</style>